<?php

include 'islogin.php';

include '../config.php';

	

if( isset($_GET['flag']))

{

	if($_GET['flag']=="update")

	{

		$sql = "select a.id,a.title,a.path,a.remark,a.dates,a._reads from en_problem as a where a.flag =1 and a.id=".$_GET['id'];

		$result = mysql_query($sql);

		$row = mysql_fetch_array($result);

	}

}

if(isset($_POST['flag']))

{

	if($_POST['flag']=="update")

	{

		$sql = "update en_problem set title='".$_POST['title']."', path='".$_POST['path']."', remark ='".$_POST['remark']."',_reads =".$_POST['_reads']." ,dates = '".$_POST['dates']."' where id =".$_POST['id'];

		mysql_query($sql);

		echo $sql;

		echo "<script>window.location.href='problem_list.php'</script>";

	}

	if($_POST['flag']=="add")

	{

		$sql = "insert into en_problem(title,path,remark,dates,_reads,flag) values('".$_POST['title']."','".$_POST['path']."','".$_POST['remark']."', '".$_POST['dates']."',".$_POST['_reads'].",1)";

		

		mysql_query($sql);

		echo "<script>window.location.href='problem_list.php'</script>";

	}

	

}

?>

<script src="../js/jquery-1.7.1.js"></script>

<link href="images/skin.css" rel="stylesheet" type="text/css" />

<link href="css/right.css" rel="stylesheet" type="text/css"/>

<link href="js/upload/uploadify.css" rel="stylesheet" type="text/css" />

<script src="js/upload/swfobject.js"></script>

<script src="js/upload/jquery.uploadify.v2.1.4.min.js"></script>
<style>
   #img_uploadUploader{vertical-align:middle}
</style>
<script>

	$(document).ready(function(){



		   $('#img_upload').uploadify({

			   'uploader':'js/upload/uploadify.swf',

			   'cancelImg':'js/upload/cancel.png',

			   'fileExt':'*.png',

			   'script':'uploadify.php',

			   'auto':true,

			   'folder':'upload',

			   'buttonImg':'images/Browse.png',

			   'width':70,

			   'height':25,

			   'wmode':'transparent',

			   'onComplete':function(event,queueId,fileObj,response,data){

				   	 

				     $("#path").val(response);

				   }

	     });

		});

</script>

<div style="border:0px solid red;"> 



    	<div id="top"><div>服务公告</div></div>

    	

	    <div id="middle">

	     <div class="layout">

		  	<div class="title">公告管理</div>

		       <div class="content">

			       <form action="problem_add.php" method="post">

			         <input type="hidden" name="flag" value="<?php if(isset($row)){echo "update";}else{echo "add";}?>" />

			         <input type="hidden" name="id" value="<?php if(isset($row)){echo $row['id'];}?>" />

			          <table  cellspacing="0" cellpadding="0">  

			          	<tr>

			          		<td class="title_some_td" style="width:100px;">公告标题:</td>

			          		<td><input name="title" value="<?php if(isset($row)){echo $row['title'];}?>"  /></td>

			          	</tr>

			          	<tr>

			          		<td class="title_some_td" style="width:100px;">公告图片:</td>

			          		<td><input id="path" name="path" value="<?php if(isset($row)){echo $row['path'];}?>"  /> <input id="img_upload" /></td>

			          	</tr>

			          

			        

			          	<tr>

			          		<td class="title_some_td" style="width:100px;">公告日期:</td>

			          		<td><input name="dates" value="<?php if(isset($row)){echo $row['dates'];}?>"  /><span>格式:2012-02-02</span></td>

			          	</tr>

			          	<tr>

			          		<td class="title_some_td" style="width:100px;">阅读数:</td>

			          		<td><input name="_reads" value="<?php if(isset($row)){echo $row['_reads'];}?>"  /></td>

			          	</tr>

			          	

			          	 <tr>

			          		<td class="title_some_td" style="width:100px;">公告简介:</td>

			          		<td><textarea style="" rows="5" cols="30" name="remark"><?php if(isset($row)){echo $row['remark'];}?></textarea></td>

			          	</tr>

			          	<tr>

			          		<td></td>

			          		<td><input type="submit" value="保存" /></td>

			          	</tr>

			          </table>

			      </form>    

		      </div>

		  </div>

	    </div>

	    

	    <div id="bottom"></div>		

</div>	    